package cn.sytton.taffe.framework.request.config;

import cn.sytton.taffe.framework.request.RepeatedlyRequestBodyFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;

/**
 * request过滤器配置
 *
 * @author skyrock
 */
@Configuration
public class RequestFilterConfig {

    // RequestBody流复制，可以重复读取
    @Bean
    public FilterRegistrationBean<RepeatedlyRequestBodyFilter> requestBodyBean(){

        FilterRegistrationBean<RepeatedlyRequestBodyFilter> bean = new FilterRegistrationBean<RepeatedlyRequestBodyFilter>();

        bean.setName("RepeatedlyRequestBodyFilter");
        bean.setFilter(new RepeatedlyRequestBodyFilter());
        bean.addUrlPatterns("/*");  //过滤所有请求
        bean.setOrder(Ordered.LOWEST_PRECEDENCE);

        return bean;
    }
}
